package com.codefish.framework.spring.beans.factory.config;

import com.codefish.framework.spring.beans.exception.BeansException;
import com.codefish.framework.spring.core.utils.LogUtils;
import com.codefish.framework.spring.core.utils.Logger;

/**
 * 显示Bean初始化前后的日志
 *
 * @author <a href='https://gitee.com/hzf2281'>codefish</a>
 * @version 1.0.0
 * @since 2022/10/03 下午 03:11
 */
public class ShowLogBeanPostProcessor implements IBeanPostProcessor {
    private static final Logger log = LogUtils.getLogger(ShowLogBeanPostProcessor.class);

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        log.info("执行bean的init-method前调用，beanName：'%s',beanObj:[%s]", beanName, bean.toString());
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        log.info("执行bean的init-method后调用，beanName：'%s',beanObj:[%s]", beanName, bean.toString());
        return bean;
    }
}
